//
//  MessageObject.h
//  EWork
//
//  Created by Reese on 13-8-11.
//  Copyright (c) 2013年 Reese. All rights reserved.
//

#import <Foundation/Foundation.h>

#define kMESSAGE_TYPE @"messageType"
#define kMESSAGE_FROM @"messageFrom"
#define kMESSAGE_TO @"messageTo"
#define kMESSAGE_CONTENT @"messageContent"
#define kMESSAGE_DATE @"messageDate"
#define kMESSAGE_ID @"messageId"

enum kMessageType {
    kMessageTypePlain = 0,
    kMessageTypeImage = 1,
    kMessageTypeVoice =2,
    kMessageTypeLocation=3
};

enum kMessageCellStyle {
    kMessageCellStyleMe = 0,
    kMessageCellStyleOther = 1,
    kMessageCellStyleMeWithImage=2,
    kMessageCellStyleOtherWithImage=3
};

@interface MessageObject : NSObject
@property (nonatomic,retain) NSString *messageFrom;
@property (nonatomic,retain) NSString *messageTo;
@property (nonatomic,retain) NSString *messageContent;
@property (nonatomic,retain) NSDate *messageDate;
@property (nonatomic,retain) NSNumber *messageType;
@property (nonatomic,retain) NSNumber *messageId;

+(MessageObject *)messageWithType:(int)aType;

//将对象转换为字典
-(NSDictionary*)toDictionary;
+(MessageObject*)messageFromDictionary:(NSDictionary*)aDic;

//数据库增删改查
+(BOOL)save:(MessageObject*)aMessage;
/*
+(BOOL)deleteMessageById:(NSNumber*)aMessageId;
+(BOOL)merge:(MessageObject*)aMessage;
 */

//获取某联系人聊天记录
+(NSMutableArray *)fetchMessageListWithUser:(NSString *)userId byPage:(int)pageIndex;

//获取最近联系人
+(NSMutableArray *)fetchRecentChatByPage:(int)pageIndex;

@end
